/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package merlion.frm.bpm.entity;

import java.io.Serializable;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToOne;
import merlion.common.entity.DocFile;

/**
 *
 * @author Yuwei
 */
@Entity
public class SupplierReceipt implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;
    private String supplierReceiptNo;
    private double receiptAmount;
    @OneToOne(targetEntity=SupplierPaymentRecord.class, cascade={CascadeType.ALL}, fetch=FetchType.EAGER, mappedBy="supplierReceipt")
    private SupplierPaymentRecord supplierPaymentRecord;
    @OneToOne(targetEntity = DocFile.class, cascade = {CascadeType.ALL}, fetch = FetchType.EAGER)
    private DocFile uploadedImage;

    public SupplierReceipt(){
        supplierReceiptNo = "";
        receiptAmount = (double)0;
        supplierPaymentRecord = new SupplierPaymentRecord();
    }
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getSupplierReceiptNo() {
        return supplierReceiptNo;
    }

    public void setSupplierReceiptNo(String supplierReceiptNo) {
        this.supplierReceiptNo = supplierReceiptNo;
    }

    public double getReceiptAmount() {
        return receiptAmount;
    }

    public void setReceiptAmount(double receiptAmount) {
        this.receiptAmount = receiptAmount;
    }

    public SupplierPaymentRecord getSupplierPaymentRecord() {
        return supplierPaymentRecord;
    }

    public void setSupplierPaymentRecord(SupplierPaymentRecord supplierPaymentRecord) {
        this.supplierPaymentRecord = supplierPaymentRecord;
    }

    public DocFile getUploadedImage() {
        return uploadedImage;
    }

    public void setUploadedImage(DocFile uploadedImage) {
        this.uploadedImage = uploadedImage;
    }
    
    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        if (!(object instanceof SupplierReceipt)) {
            return false;
        }
        SupplierReceipt other = (SupplierReceipt) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "merlion.frm.bpm.entity.SupplierReceipt[ id=" + id + " ]";
    }
    
}
